package com.nowcoder.community.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

//@Component
//@Aspect
public class AlphaAspect {

    //声明切点，Pointcut织入到哪些对象的哪些位置
    @Pointcut("execution(* com.nowcoder.community.service.*.*(..))")
    public void pointCUT(){

    }

    @Before("pointCUT()")
    public void before(){
        System.out.println("before");
    }

    @After("pointCUT()")
    public void after(){
        System.out.println("after");
    }

    @AfterReturning("pointCUT()")
    public void afterRunning(){
        System.out.println("afterRunning");
    }

    @AfterThrowing("pointCUT()")
    public void afterThrowing(){
        System.out.println("afterThrowing");
    }

    @Around("pointCUT()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
        System.out.println("around before");
        Object proceed = joinPoint.proceed();
        System.out.println("around after");
        return proceed;
    }

}
